package level.editor.view.action.frame;

import java.awt.event.ActionEvent;

import level.editor.view.action.DesktopAction;
import level.editor.view.base.BasePanel;
import level.editor.view.base.PanelConstants;
import level.editor.view.desktop.Desktop;

public class RemovePanelAction extends DesktopAction
{
	public RemovePanelAction(Desktop desktop, Boolean direction)
	{
		super("Remove "
				+ (direction.equals(PanelConstants.LEFT) ? "left" : "right")
				+ " Panel", desktop);
		this.direction = direction;
	}

	@Override
	public void actionPerformed(ActionEvent e)
	{
		if (direction != null)
		{
			if (desktop != null)
			{
				BasePanel base = desktop.getBasePanel();
				if (base != null)
				{
					base.removePanel(direction);
					desktop.revalidate();
				}
			}
		}
		else
			System.out.println("Error in RemovePanelAction");
	}

	private Boolean direction;
}
